package com.nenude.corejava.works;

import java.util.Scanner;

public class Factorial {
	//用递归求n!
	
	public static void main(String[] args) {
		System.out.println("输入一个数： ");
		Scanner scanner=new Scanner(System.in);
		int  n=scanner.nextInt();
		
		for(int i=0;i<=n;i++){
			
			int result= new Factorial().fatorial(i);//调用方法
			System.out.println(i+"的阶乘是： " +result);
		}		
	}
	
	
	public int  fatorial(int n){
		if(n<1){
			return 1;
		}
		return fatorial(n-1)*n;
	}	
}
